<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <meta name="renderer" content="webkit">
  <title></title>
  <link rel="stylesheet" href="/Public/Admin/css/pintuer.css">
  <link rel="stylesheet" href="/Public/Admin/css/admin.css">
  <script src="/Public/Admin/js/jquery.js"></script>
  <script src="/Public/Admin/js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head"><strong class="icon-reorder"> 产品列表</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
  <div class="padding border-bottom">

    <ul class="search" style="padding-left:10px;">
      <form action="/Admin/Product/index" method="get">
        <ul class="search" style="padding-left:10px;">
          <li>
            <input type="text" placeholder="请输入搜索关键字" name="keywords" class="input" style="width:250px; line-height:17px;display:inline-block" value="<?php echo ($keywords); ?>" />
          </li>
          <li><input type="submit" class="button border-main icon-search" value="搜索"></li>
          <li>
            <button type="button" class="button border-yellow" onclick="window.location.href='/Admin/Product/addProduct'"><span class="icon-plus-square-o"></span> 添加产品</button>
          </li>
        </ul>
      </form>

    </ul>

  </div>
  <table class="table table-hover text-center">
    <tr>
      <th width="100" style=" padding-left:20px;">序号</th>
      <th>标题</th>
      <th>价格</th>
      <th>展示图</th>
      <th>添加时间</th>
      <th width="300px">操作</th>
    </tr>
    <?php $num = $pages['page']+1; ?>
    <?php if(is_array($lists)): $i = 0; $__LIST__ = $lists;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
        <td style=" padding-left:20px;"><?php echo ($num++); ?></td>
        <td><?php echo ($vo["name"]); ?></td>
        <td>￥<?php echo ($vo["price"]); ?></td>
        <td><img src="<?php echo ($vo["pic"]); ?>" width="120" height="120"></td>

        <td><?php echo ($vo["add_time"]); ?></td>
        <td>
          <div class="button-group">
            <a class="button border-yellow" href="/Admin/Product/addProduct/id/<?php echo ($vo["id"]); ?>/page/<?php echo ($pages["page"]); ?>"><span class="icon-edit"></span>编辑内容</a>
            <a class="button border-red" href="javascript:void(0)" onclick="return del(<?php echo ($vo["id"]); ?>)"><span class="icon-trash-o"></span> 删除</a>
          </div></td>
      </tr><?php endforeach; endif; else: echo "" ;endif; ?>
    <tr>
      <td colspan="12">
        <?php if($lists == null): ?>暂无信息
          <?php else: ?>
          <div class="pagelist">
            <a href="/Admin/Product/index/cate_id/<?php echo ($cate_id); ?>/page/0">首页</a>
            <a href="/Admin/Product/index/cate_id/<?php echo ($cate_id); ?>/page/<?php echo ($pages['page']-1); ?>">上一页</a>
            <?php if(is_array($pages["num"])): foreach($pages["num"] as $key=>$p): if($p-1 == $pages['page']): ?><span class="current"><?php echo ($p); ?></span>
                <?php else: ?>
                <a href="/Admin/Product/index/cate_id/<?php echo ($cate_id); ?>/page/<?php echo ($p-1); ?>"><?php echo ($p); ?></a><?php endif; endforeach; endif; ?>
            <a href="/Admin/Product/index/cate_id/<?php echo ($cate_id); ?>/page/<?php echo ($pages['page']+1); ?>">下一页</a>
            <a href="/Admin/Product/index/cate_id/<?php echo ($cate_id); ?>/page/<?php echo ($pages['total']); ?>">尾页</a>
          </div><?php endif; ?>
      </td>
    </tr>
  </table>
</div>
<script type="text/javascript">

  $("body").bind("keydown",function(event){
    if (event.keyCode == 116) {
      event.preventDefault(); //阻止默认刷新
      //location.reload();
      //采用location.reload()在火狐下可能会有问题，火狐会保留上一次链接
      location=location;
    }
  })

  //产品状态
  function changeStatus(id,tag){
    var txt		=	tag == '1' ?'您确定要继续出售?':'您确定停止出售?';
    if(confirm(txt)){
      $.ajax({
        url:"/Admin/Product/changeStatus",
        type:"get",
        data:{
          'id':id,
          'tag':tag
        },
        success:function(data){
          if(data){
            alert("操作成功");
            location.reload();
          }
          else alert("操作失败");
        }
      })
    }
  }

  //单个删除
  function del(id){
    if(confirm("您确定要删除吗?")){
      $.ajax({
        url:"/Admin/Index/delData",
        type:"get",
        data:{
          'id':id,
          'table':'product'
        },
        success:function(data){
          if(data){
            alert("删除成功");
            location.reload();
          }
          else alert("删除失败");
        }
      })
    }
  }

  //全选
  $("#checkall").click(function(){
    $("input[name='id[]']").each(function(){
      if (this.checked) {
        this.checked = false;
      }
      else {
        this.checked = true;
      }
    });
  })

  //批量删除
  function DelSelect(){
    var Checkbox=false;
    $("input[name='id[]']").each(function(){
      if (this.checked==true) {
        Checkbox=true;
      }
    });
    if (Checkbox){
      var t=confirm("您确认要删除选中的内容吗？");
      if (t==false) return false;
      $("#listform").submit();
    }
    else{
      alert("请选择您要删除的内容!");
      return false;
    }
  }

  //批量排序
  function sorts(){
    var Checkbox=false;
    $("input[name='id[]']").each(function(){
      if (this.checked==true) {
        Checkbox=true;
      }
    });
    if (Checkbox){

      $("#listform").submit();
    }
    else{
      alert("请选择要操作的内容!");
      return false;
    }
  }


  //批量首页显示
  function changeishome(o){
    var Checkbox=false;
    $("input[name='id[]']").each(function(){
      if (this.checked==true) {
        Checkbox=true;
      }
    });
    if (Checkbox){

      $("#listform").submit();
    }
    else{
      alert("请选择要操作的内容!");

      return false;
    }
  }

  //批量推荐
  function changeisvouch(o){
    var Checkbox=false;
    $("input[name='id[]']").each(function(){
      if (this.checked==true) {
        Checkbox=true;
      }
    });
    if (Checkbox){


      $("#listform").submit();
    }
    else{
      alert("请选择要操作的内容!");

      return false;
    }
  }

  //批量置顶
  function changeistop(o){
    var Checkbox=false;
    $("input[name='id[]']").each(function(){
      if (this.checked==true) {
        Checkbox=true;
      }
    });
    if (Checkbox){

      $("#listform").submit();
    }
    else{
      alert("请选择要操作的内容!");

      return false;
    }
  }


  //批量移动
  function changecate(o){
    var Checkbox=false;
    $("input[name='id[]']").each(function(){
      if (this.checked==true) {
        Checkbox=true;
      }
    });
    if (Checkbox){

      $("#listform").submit();
    }
    else{
      alert("请选择要操作的内容!");

      return false;
    }
  }

  //批量复制
  function changecopy(o){
    var Checkbox=false;
    $("input[name='id[]']").each(function(){
      if (this.checked==true) {
        Checkbox=true;
      }
    });
    if (Checkbox){
      var i = 0;
      $("input[name='id[]']").each(function(){
        if (this.checked==true) {
          i++;
        }
      });
      if(i>1){
        alert("只能选择一条信息!");
        $(o).find("option:first").prop("selected","selected");
      }else{

        $("#listform").submit();
      }
    }
    else{
      alert("请选择要复制的内容!");
      $(o).find("option:first").prop("selected","selected");
      return false;
    }
  }

</script>
</body>
</html>